<template>
  <h2>角色添加</h2>
  <div>
    <el-form :model="form" label-width="auto" style="max-width: 400px">
      <el-form-item label="角色名称：">
        <el-input v-model="form.roleName" />
      </el-form-item>
      <el-form-item>
      <el-button type="primary" @click="onSubmit">保存</el-button>
        <el-button>Cancel</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { reactive } from 'vue'

const form = reactive({
  roleName: '',
})
import { ElMessage } from 'element-plus'
import router from '@/router';
//角色保存
const onSubmit = () => {
  axios.post(`Role/Create`,form).then((ret) => {
    console.log(ret.data)
    if(ret.data.code==1){
      ElMessage.success('添加成功')
      router.push('/RoleList')
      return
    }else{
      ElMessage.error(ret.data.message)
    }
  })
}

</script>

<style scoped>

</style>